package top.tenebrous.yzl.im.enums;

import lombok.Getter;

/**
 * 消息类型枚举
 * @author yazhang6
 */
@Getter
public enum MessageType {

    AUTH("10001","AUTH"),
    AUTH_COMPLETED("10002","AUTH_COMPLETED"),
    PUT("20001", "PUT_MESSAGE"),
    LIST("30001", "LIST_MESSAGE"),
    SYSTEM("40001", "SYSTEM_MESSAGE"),
    ERROR("50001", "ERROR_MESSAGE");

    private final String code;
    private final String value;

    private MessageType(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public static MessageType getMessageType(String code) {
        for (MessageType messageType : values()) {
            if (messageType.code.equals(code)) {
                return messageType;
            }
        }
        throw new IllegalArgumentException("unknown data type code");
    }
}
